function [irfa] = irf_select(irfa, iv, IRFind, indlev)
% ================================================================
%       Selecting impulse-responses IRF
%   INPUT:
%       irfa   - impulse response function (see also var_irf.m)
%       iv     - variable that responds to a shock (can be a vector) 
%       IRFind - variable to which we have a shock 
%       indlev - set to 1 for cumulative IRF, set to 0 for the standar IRF

[N,N,q]=size(irfa); %q is the number of periods for which IRF are computed 
irfa = reshape(irfa,N,N*q);
    

indR   = IRFind:N:N*q;
indR   = indR';
irfa   = irfa(iv, indR);       % Selecting impulse-responses
if indlev == 1
    irfa = cumsum(irfa')';
end